﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Way.Bus.Controllers;
using Way.EAP.DataAccess.Entity;
using Way.Contract.Data.ControllerData;
using Way.EAP.DataAccess.Data;
using Way.Contract.Data;
using Way.Contract;
using Way.EAP.DataAccess.Regulation;
using Way.Bus.WMS.Model;
using Way.Bus.WMS.ST.Model;
using Way.Bus.WMS.ST.Controllers.Company;
using Way.Contract.MVC;

namespace  Way.Bus.WMS.ST.Controllers.Custemer
{
    public class CustomerController : CompanyController
    {

        //显示在菜单
        protected override string OnControllerName()
        {
            return "客户管理";
        }
        //菜单中url路径
        protected override string OnGetPath()
        {
            return "Views/ST/Customer/Customers.htm";
        }
        //说明
        protected override string OnGetControllerDescription()
        {
            return "客户管理";
        }
        public static void InitCustemer(ModelData data, ItemData item)
        {
            data.title = "客户";
            if (item.IsField("FTYPE"))
            {
                item.visible = false;
            }
        }
        protected override void OnInitViewChildItem(ModelData data, ItemData item)
        {
            base.OnInitViewChildItem(data, item);
            if (data.name.EndsWith("ST_Customer"))
            {
                InitCustemer(data, item);
            }
            if (data.name.EndsWith("ST_CustomerAdress"))
            {
                data.title = "客户联系信息";
            }
            if (data.name.EndsWith("ST_Materials") || ((data.parent != null) && data.parent.name.EndsWith("ST_Materials")))
            {
                MaterialsController.InitMaterials(data, item);
                if (item.IsField("STAY10"))
                {
                    item.visible = false;
                }
            }
        }
        protected override void OnAdding(Way.Contract.MVC.ControllerBase.SaveEvent item)
        {
            item.Item["FTYPE"] = 2;
            base.OnAdding(item);
        }
        protected override void OnGetWhereing(IModel m, List<Way.EAP.DataAccess.Regulation.SQLWhere> where, loadItem item)
        {
            base.OnGetWhereing(m, where, item);
            if (item.selectTag == null || item.selectTag is ST_Customer)
            {
                SQLWhere sw = new SQLWhere();
                sw.ColumnName = "FTYPE";
                sw.Value = "2";
                where.Add(sw);
            }
        }
      
       

    }
}

